package chatroom;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Author Gong
 * @Description
 * @dATE 2022/4/18 16:37
 **/
@WebServlet("/logoOutServlet")  //不能重名
public class LogoOutServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        if(null != session){
            session.invalidate();
        }
        resp.sendRedirect(req.getContextPath()+"/index.jsp");
    }
}
